home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
bbsutil
/
bsrc_250.zip
/
ZMISC.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-15
|
22KB
|
742 lines
/*--------------------------------------------------------------------------*/
/* */
/* */
/* ------------ Bit-Bucket Software, Co. */
/* \ 10001101 / Writers and Distributors of */
/* \ 011110 / Freely Available<tm> Software. */
/* \ 1011 / */
/* ------ */
/* */
/* (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
/* */
/* */
/* Zmodem routines used by Zsend and Zreceive */
/* */
/* */
/* For complete details of the licensing restrictions, please refer */
/* to the License agreement, which is published in its entirety in */
/* the MAKEFILE and BT.C, and also contained in the file LICENSE.250. */
/* */
/* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
/* BINKLEYTERM LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
/* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
/* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT BIT BUCKET */
/* SOFTWARE CO. AT ONE OF THE ADDRESSES LISTED BELOW. IN NO EVENT */
/* SHOULD YOU PROCEED TO USE THIS FILE WITHOUT HAVING ACCEPTED THE */
/* TERMS OF THE BINKLEYTERM LICENSING AGREEMENT, OR SUCH OTHER */
/* AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO. */
/* */
/* */
/* You can contact Bit Bucket Software Co. at any one of the following */
/* addresses: */
/* */
/* Bit Bucket Software Co. FidoNet 1:104/501, 1:343/491 */
/* P.O. Box 460398 AlterNet 7:491/0 */
/* Aurora, CO 80046 BBS-Net 86:2030/1 */
/* Internet f491.n343.z1.fidonet.org */
/* */
/* Please feel free to contact us at any time to share your comments about */
/* our software and/or licensing policies. */
/* */
/* */
/* This module is based largely on a similar module in OPUS-CBCS V1.03b. */
/* The original work is (C) Copyright 1986, Wynn Wagner III. The original */
/* authors have graciously allowed us to use their code in this work. */
/* */
/*--------------------------------------------------------------------------*/
/* Include this file before any other includes or defines! */
#include "includes.h"
static int Rxtype; /* Type of header received */
static char hex[] = "0123456789abcdef";
/* Send a byte as two hex digits */
#define Z_PUTHEX(i,c) {i=(c);SENDBYTE(hex[((i)&0xF0)>>4]);SENDBYTE(hex[(i)&0xF]);}
/*--------------------------------------------------------------------------*/
/* Private routines */
/*--------------------------------------------------------------------------*/
int _Z_GetBinaryHeader (unsigned char *);
int _Z_32GetBinaryHeader (unsigned char *);
int _Z_GetHexHeader (unsigned char *);
int _Z_GetHex (void);
int _Z_TimedRead (void);
long _Z_PullLongFromHeader (unsigned char *);
#ifdef MILQ
/*
* Dst - Where to put this. Should use a static buffer, if
* a destination is not provided
*
* Src - The filename to be conditioned
*
* TblNm - Name of the file to use for the source of path
* conditioning entries
*
* Mode -
*/
char *ZMdmFlNmCndtn( char *Dst,
char *Src,
char *Tbl,
int Mode ) {
char *p;
char *q;
for ( p = Src, q = Dst; *p; ) {
switch ( *p ) {
case '/':
case '\\':
switch ( UsePaths ) {
case FALSE:
q = Dst;
break;
default:
*q++ = '/';
break;
} /* end of switch ( UsePaths ) */
break;
case ':':
q = Dst;
break;
default:
*q++ = (char) tolower (*p);
break;
} /* end of for ( p = Src ... ) */
p++;
}
*q++ = '\0';
return Dst;
}
#endif
void z_message (char *s)
{
if (fullscreen && un_attended)
{
if (s)
{
sb_move (file_hWnd, 2, 27);
FlLnModeSet( FILE_LN_2, 0 );
sb_puts( GetDlgItem( file_hWnd, FILE_LN_2 + GD_STATUS ), s );
}
#ifndef MILQ
sb_puts (file_hWnd, " ");
#endif
sb_show ();
}
else
{
gotoxy (locate_x + 20, locate_y);
if (s)
{
(void) cputs (s);
}
(void) cputs (" ");
}
}
void z_log (char *s)
{
word x, y;
z_message (s);
x = locate_x;
y = locate_y;
status_line (s); /* also does disk file
* logging */
locate_x = x;
locate_y = y;
}
void show_loc (unsigned long l, unsigned int w)
{
char j[100];
if (fullscreen && un_attended)
{
(void) sprintf (j, "Ofs=%ld Retries=%d ", l, w);
sb_move (file_hWnd, 2, 37);
sb_puts( GetDlgItem( file_hWnd, FILE_LN_2 + GD_SIZE ), j );
sb_show ();
}
else
{
gotoxy (locate_x + 35, locate_y);
(void) printf ("Ofs=%ld Retries=%d ", l, w);
}
}
/*--------------------------------------------------------------------------*/
/* Z GET BYTE */
/* Get a byte from the modem; */
/* return TIMEOUT if no read within timeout tenths, */
/* return RCDO if carrier lost */
/*--------------------------------------------------------------------------*/
int Z_GetByte (int tenths)
{
long timeout;
if (PEEKBYTE () >= 0)
return (MODEM_IN ());
timeout = timerset (tenths * 10);
do
{
if (PEEKBYTE () >= 0)
return MODEM_IN ();
if (!CARRIER)
return RCDO;
if (got_ESC ())
return -1;
time_release ();
}
while (!timeup (timeout));
return TIMEOUT;
}
/*--------------------------------------------------------------------------*/
/* Z PUT STRING */
/* Send a string to the modem, processing for \336 (sleep 1 sec) */
/* and \335 (break signal, ignored) */
/*--------------------------------------------------------------------------*/
void Z_PutString (register unsigned char *s)
{
register unsigne